
rm(list=ls(all=TRUE))

### load packages
library(foreign)
library(xtable)
library(MASS)
library(sandwich)
library(lmtest)
library(lattice)
library(stargazer)
library(MatchIt)
library(SDMTools)


### set seet
set.seed(123)


### set working directory
setwd("~/Desktop/replication")


### Functions to be used 
t.test.noweight <- function(var0, var1){
	mean0 <- mean(var0)
	mean1 <- mean(var1)

	s0 <- sd(var0)
	s1 <- sd(var1)

	n0 <- length(var0)
	n1 <- length(var1)

	se <- sqrt(((s1^2)/n1) + ((s0^2)/n0))

	df <- ((((s1^2)/n1) + ((s0^2)/n0))^2) / ( ((((s1^2)/n1)^2)/(n1-1)) + ((((s0^2)/n0)^2)/(n0-1)) )

	t <- ((mean0-mean1))/se
	p <- 2*pt(abs(t), df, lower=FALSE)
	out <- list(estimate = c(mean0, mean1), p.value=p)
	out
}

t.test.weight <- function(var0, var1, weight0, weight1){
	mean0 <- wt.mean(var0, weight0)
	mean1 <- wt.mean(var1, weight1)

	s0 <- wt.sd(var0, weight0)
	s1 <- wt.sd(var1, weight1)

	n0 <- length(var0)
	n1 <- length(var1)

	se <- sqrt(((s1^2)/n1) + ((s0^2)/n0))

	df <- ((((s1^2)/n1) + ((s0^2)/n0))^2) / ( ((((s1^2)/n1)^2)/(n1-1)) + ((((s0^2)/n0)^2)/(n0-1)) )

	t <- ((mean0-mean1))/se
	p <- 2*pt(abs(t), df, lower=FALSE)
	out <- list(estimate = c(mean0, mean1), p.value=p)
	out
}

se <- function(x) sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))

### Load data
data <- read.dta("survey_experiment_data.dta")




#######################
### MAIN MANUSCRIPT ###
#######################


### Table 1
meandiff <- NULL

bla <- t.test(data$resign ~ data$enrich_treat)
p1 <- bla$p.value
se1 <- sqrt((sd(data$resign[data$enrich_treat==0], na.rm=T)/ length(data$resign[is.na(data$resign)==F & data$enrich_treat==0])) + (sd(data$resign[data$enrich_treat==1], na.rm=T)/ length(data$resign[is.na(data$resign)==F & data$enrich_treat==1])))
meandiff <- rbind(meandiff, c("Resign", round(rev(bla$estimate), 3), round(bla$estimate[2]-bla$estimate[1], 3), round(se1, 3), round(p1, 3)))

bla <- t.test(data$ban ~ data$enrich_treat)
p2 <- bla$p.value
se2 <- sqrt((sd(data$ban[data$enrich_treat==0], na.rm=T)/ length(data$ban[is.na(data$ban)==F & data$enrich_treat==0])) + (sd(data$ban[data$enrich_treat==1], na.rm=T)/ length(data$ban[is.na(data$ban)==F & data$enrich_treat==1])))
meandiff <- rbind(meandiff, c("Ban", round(rev(bla$estimate), 3), round(bla$estimate[2]-bla$estimate[1], 3), round(se2, 3), round(p2, 3)))

bla <- t.test(data$jail ~ data$enrich_treat)
p3 <- bla$p.value
se3 <- sqrt((sd(data$jail[data$enrich_treat==0], na.rm=T)/ length(data$jail[is.na(data$jail)==F & data$enrich_treat==0])) + (sd(data$jail[data$enrich_treat==1], na.rm=T)/ length(data$jail[is.na(data$jail)==F & data$enrich_treat==1])))
meandiff <- rbind(meandiff, c("Jail", round(rev(bla$estimate), 3), round(bla$estimate[2]-bla$estimate[1], 3), round(se3, 3), round(p3, 3)))

# add p-values, adjusted for multiple comparisons
meandiff <- cbind(meandiff, round(p.adjust(c(p1, p2, p3), method="BY"), 3))

xtable(meandiff)



### Figure 1
resign_enrich <- prop.table(table(factor(data$resign[data$enrich_treat==0], levels=1:5)))
resign_enrich_low <- resign_enrich + qnorm(0.025)*sqrt((resign_enrich*(1-resign_enrich))/(length(data$resign[is.na(data$resign)==F])))
resign_enrich_high <- resign_enrich + qnorm(0.975)*sqrt((resign_enrich*(1-resign_enrich))/(length(data$resign[is.na(data$resign)==F])))

resign_votebuy <- prop.table(table(factor(data$resign[data$enrich_treat==1], levels=1:5)))
resign_votebuy_low <- resign_votebuy + qnorm(0.025)*sqrt((resign_votebuy*(1-resign_votebuy))/(length(data$resign[is.na(data$resign)==F])))
resign_votebuy_high <- resign_votebuy + qnorm(0.975)*sqrt((resign_votebuy*(1-resign_votebuy))/(length(data$resign[is.na(data$resign)==F])))

ban_enrich <- prop.table(table(factor(data$ban[data$enrich_treat==0], levels=1:5)))
ban_enrich_low <- ban_enrich + qnorm(0.025)*sqrt((ban_enrich*(1-ban_enrich))/(length(data$ban[is.na(data$ban)==F])))
ban_enrich_high <- ban_enrich + qnorm(0.975)*sqrt((ban_enrich*(1-ban_enrich))/(length(data$ban[is.na(data$ban)==F])))

ban_votebuy <- prop.table(table(factor(data$resign[data$enrich_treat==1], levels=1:5)))
ban_votebuy_low <- ban_votebuy + qnorm(0.025)*sqrt((ban_votebuy*(1-ban_votebuy))/(length(data$ban[is.na(data$ban)==F])))
ban_votebuy_high <- ban_votebuy + qnorm(0.975)*sqrt((ban_votebuy*(1-ban_votebuy))/(length(data$ban[is.na(data$ban)==F])))

jail_enrich <- prop.table(table(factor(data$jail[data$enrich_treat==0], levels=1:5)))
jail_enrich_low <- jail_enrich + qnorm(0.025)*sqrt((jail_enrich*(1-jail_enrich))/(length(data$jail[is.na(data$jail)==F])))
jail_enrich_high <- jail_enrich + qnorm(0.975)*sqrt((jail_enrich*(1-jail_enrich))/(length(data$jail[is.na(data$jail)==F])))

jail_votebuy <- prop.table(table(factor(data$jail[data$enrich_treat==1], levels=1:5)))
jail_votebuy_low <- jail_votebuy + qnorm(0.025)*sqrt((jail_votebuy*(1-jail_votebuy))/(length(data$jail[is.na(data$jail)==F])))
jail_votebuy_high <- jail_votebuy + qnorm(0.975)*sqrt((jail_votebuy*(1-jail_votebuy))/(length(data$jail[is.na(data$jail)==F])))


tab <- matrix(c(resign_enrich[1], ban_enrich[1], jail_enrich[1], resign_votebuy[1], ban_votebuy[1], jail_votebuy[1]), nrow=2, byrow=T)
colnames(tab) <- c("Resign", "Ban", "Jail")
rownames(tab) <- c("Enrichment", "Vote Buying")

tablow <- c(resign_enrich_low[1], resign_votebuy_low[1], ban_enrich_low[1], ban_votebuy_low[1], jail_enrich_low[1], jail_votebuy_low[1])
tabhigh <- c(resign_enrich_high[1], resign_votebuy_high[1], ban_enrich_high[1], ban_votebuy_high[1], jail_enrich_high[1], jail_votebuy_high[1])


quartz(type="pdf", width=5*1.62, height=5, file="experiment_agreecompletely.pdf")
par(mar = c(4,4,2,2), mgp=c(2.5,1,0), fg='#000000', bg='#ffffff', col='#000000', col.axis='#000000', col.lab='#000000', col.main='#000000', col.sub='#000000')

bla <- barplot(tab, ylab="Share of Respondents", col=c("gray","white"), beside=TRUE, ylim=c(0, 0.82))

for(i in 1:length(bla)){
	lines(c(bla[i], bla[i]), c(tablow[i], tabhigh[i]), lwd=3)
	lines(c(bla[i]-0.1, bla[i]+0.1), c(tablow[i], tablow[i]), lwd=3)
	lines(c(bla[i]-0.1, bla[i]+0.1), c(tabhigh[i], tabhigh[i]), lwd=3)
}
dev.off()






#######################
### ONLINE APPENDIX ###
#######################


### Table 1
baltab <- NULL

bla <- t.test.noweight(data$age[data$enrich_treat==0], data$age[data$enrich_treat==1])
baltab <- rbind(baltab, c("Age", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$female[data$enrich_treat==0], data$female[data$enrich_treat==1])
baltab <- rbind(baltab, c("Female", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$hindu[data$enrich_treat==0], data$hindu[data$enrich_treat==1])
baltab <- rbind(baltab, c("Hindu", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$educ_lower[data$enrich_treat==0], data$educ_lower[data$enrich_treat==1])
baltab <- rbind(baltab, c("Education: Below Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$educ_primary[data$enrich_treat==0], data$educ_primary[data$enrich_treat==1])
baltab <- rbind(baltab, c("Education: Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$educ_matric[data$enrich_treat==0], data$educ_matric[data$enrich_treat==1])
baltab <- rbind(baltab, c("Education: Matric", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$educ_college[data$enrich_treat==0], data$educ_college[data$enrich_treat==1])
baltab <- rbind(baltab, c("Education: College", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$caste_SCST[data$enrich_treat==0], data$caste_SCST[data$enrich_treat==1])
baltab <- rbind(baltab, c("Caste: SC/ST", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$caste_OBC[data$enrich_treat==0], data$caste_OBC[data$enrich_treat==1])
baltab <- rbind(baltab, c("Caste: OBC", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$caste_Other[data$enrich_treat==0], data$caste_Other[data$enrich_treat==1])
baltab <- rbind(baltab, c("Caste: Other", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$household_adults[data$enrich_treat==0], data$household_adults[data$enrich_treat==1])
baltab <- rbind(baltab, c("Adults in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$household_child[data$enrich_treat==0], data$household_child[data$enrich_treat==1])
baltab <- rbind(baltab, c("Children in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$income_quintile_1[data$enrich_treat==0], data$income_quintile_1[data$enrich_treat==1])
baltab <- rbind(baltab, c("Income Quintile: 1", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$income_quintile_2[data$enrich_treat==0], data$income_quintile_2[data$enrich_treat==1])
baltab <- rbind(baltab, c("Income Quintile: 2", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$income_quintile_3[data$enrich_treat==0], data$income_quintile_3[data$enrich_treat==1])
baltab <- rbind(baltab, c("Income Quintile: 3", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$income_quintile_4[data$enrich_treat==0], data$income_quintile_4[data$enrich_treat==1])
baltab <- rbind(baltab, c("Income Quintile: 4", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.noweight(data$income_quintile_5[data$enrich_treat==0], data$income_quintile_5[data$enrich_treat==1])
baltab <- rbind(baltab, c("Income Quintile: 5", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(baltab)



# Table 2
catdiff <- NULL

bla <- prop.test(table(data$enrich_treat, 1-data$resign_1), correct=FALSE)
catdiff <- rbind(catdiff, c("Resign", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$resign_2), correct=FALSE)
catdiff <- rbind(catdiff, c("Resign", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$resign_3), correct=FALSE)
catdiff <- rbind(catdiff, c("Resign", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$resign_4), correct=FALSE)
catdiff <- rbind(catdiff, c("Resign", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$resign_5), correct=FALSE)
catdiff <- rbind(catdiff, c("Resign", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test(data$jail ~ data$enrich_treat)
bla <- prop.test(table(data$enrich_treat, 1-data$ban_1), correct=FALSE)
catdiff <- rbind(catdiff, c("Ban", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$ban_2), correct=FALSE)
catdiff <- rbind(catdiff, c("Ban", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$ban_3), correct=FALSE)
catdiff <- rbind(catdiff, c("Ban", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$ban_4), correct=FALSE)
catdiff <- rbind(catdiff, c("Ban", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$ban_5), correct=FALSE)
catdiff <- rbind(catdiff, c("Ban", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- prop.test(table(data$enrich_treat, 1-data$jail_1), correct=FALSE)
catdiff <- rbind(catdiff, c("Jail", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$jail_2), correct=FALSE)
catdiff <- rbind(catdiff, c("Jail", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$jail_3), correct=FALSE)
catdiff <- rbind(catdiff, c("Jail", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$jail_4), correct=FALSE)
catdiff <- rbind(catdiff, c("Jail", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- prop.test(table(data$enrich_treat, 1-data$jail_5), correct=FALSE)
catdiff <- rbind(catdiff, c("Jail", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(catdiff)



# Figure 2

resign_enrich <- prop.table(table(factor(data$resign[data$enrich_treat==0], levels=1:5)))
resign_enrich_low <- resign_enrich + qnorm(0.025)*sqrt((resign_enrich*(1-resign_enrich))/(length(data$resign[is.na(data$resign)==F])))
resign_enrich_high <- resign_enrich + qnorm(0.975)*sqrt((resign_enrich*(1-resign_enrich))/(length(data$resign[is.na(data$resign)==F])))

resign_votebuy <- prop.table(table(factor(data$resign[data$enrich_treat==1], levels=1:5)))
resign_votebuy.low <- resign_votebuy + qnorm(0.025)*sqrt((resign_votebuy*(1-resign_votebuy))/(length(data$resign[is.na(data$resign)==F])))
resign_votebuy.high <- resign_votebuy + qnorm(0.975)*sqrt((resign_votebuy*(1-resign_votebuy))/(length(data$resign[is.na(data$resign)==F])))

quartz(type="pdf", width=5*1.62, height=5, file="experiment_resign.pdf")
par(mar = c(4,4,2,2), mgp=c(2.5,1,0), fg='#000000', bg='#ffffff', col='#000000', col.axis='#000000', col.lab='#000000', col.main='#000000', col.sub='#000000')
plot(0.9:4.9, c(0, 1, 0, 0, 0) , xlim=c(0.8, 5.2), ylim=c(0,0.8), axes=F, type="n", ylab="Share of Respondents", xlab="Politician should resign")
axis(1, 1:5, c("Agree completely", "Agree", "Neither agree nor disagree", "Disagree", "Disagree completely"), cex.axis=0.8)
axis(2, c(0,0.2, 0.4, 0.6, 0.8))
for(i in 1:5){
	lines(c(i-0.1, i-0.1), c(resign_enrich_low[i], resign_enrich_high[i]), lwd=4)
	lines(c(i+0.1, i+0.1), c(resign_votebuy.low[i], resign_votebuy.high[i]), col="red", lwd=4)
}
points(0.9:4.9, resign_enrich, pch=16, cex=1.5)
points(1.1:5.1, resign_votebuy, pch=16, col="red", cex=1.5)
dev.off()


ban_enrich <- prop.table(table(factor(data$ban[data$enrich_treat==0], levels=1:5)))
ban_enrich_low <- ban_enrich + qnorm(0.025)*sqrt((ban_enrich*(1-ban_enrich))/(length(data$ban[is.na(data$ban)==F])))
ban_enrich_high <- ban_enrich + qnorm(0.975)*sqrt((ban_enrich*(1-ban_enrich))/(length(data$ban[is.na(data$ban)==F])))

ban_votebuy <- prop.table(table(factor(data$resign[data$enrich_treat==1], levels=1:5)))
ban_votebuy.low <- ban_votebuy + qnorm(0.025)*sqrt((ban_votebuy*(1-ban_votebuy))/(length(data$ban[is.na(data$ban)==F])))
ban_votebuy.high <- ban_votebuy + qnorm(0.975)*sqrt((ban_votebuy*(1-ban_votebuy))/(length(data$ban[is.na(data$ban)==F])))

quartz(type="pdf", width=5*1.62, height=5, file="experiment_ban.pdf")
par(mar = c(4,4,2,2), mgp=c(2.5,1,0), fg='#000000', bg='#ffffff', col='#000000', col.axis='#000000', col.lab='#000000', col.main='#000000', col.sub='#000000')
plot(0.9:4.9, c(0, 1, 0, 0, 0) , xlim=c(0.8, 5.2), ylim=c(0,0.8), axes=F, type="n", ylab="Share of Respondents", xlab="Politician should be banned from contesting future elections")
axis(1, 1:5, c("Agree completely", "Agree", "Neither agree nor disagree", "Disagree", "Disagree completely"), cex.axis=0.8)
axis(2, c(0,0.2, 0.4, 0.6, 0.8))
for(i in 1:5){
	lines(c(i-0.1, i-0.1), c(ban_enrich_low[i], ban_enrich_high[i]), lwd=4)
	lines(c(i+0.1, i+0.1), c(ban_votebuy.low[i], ban_votebuy.high[i]), col="red", lwd=4)
}
points(0.9:4.9, ban_enrich, pch=16, cex=1.5)
points(1.1:5.1, ban_votebuy, pch=16, col="red", cex=1.5)
dev.off()


jail_enrich <- prop.table(table(factor(data$jail[data$enrich_treat==0], levels=1:5)))
jail_enrich_low <- jail_enrich + qnorm(0.025)*sqrt((jail_enrich*(1-jail_enrich))/(length(data$jail[is.na(data$jail)==F])))
jail_enrich_high <- jail_enrich + qnorm(0.975)*sqrt((jail_enrich*(1-jail_enrich))/(length(data$jail[is.na(data$jail)==F])))

jail_votebuy <- prop.table(table(factor(data$jail[data$enrich_treat==1], levels=1:5)))
jail_votebuy.low <- jail_votebuy + qnorm(0.025)*sqrt((jail_votebuy*(1-jail_votebuy))/(length(data$jail[is.na(data$jail)==F])))
jail_votebuy.high <- jail_votebuy + qnorm(0.975)*sqrt((jail_votebuy*(1-jail_votebuy))/(length(data$jail[is.na(data$jail)==F])))

quartz(type="pdf", width=5*1.62, height=5, file="experiment_jail.pdf")
par(mar = c(4,4,2,2), mgp=c(2.5,1,0), fg='#000000', bg='#ffffff', col='#000000', col.axis='#000000', col.lab='#000000', col.main='#000000', col.sub='#000000')
plot(0.9:4.9, c(0, 1, 0, 0, 0) , xlim=c(0.8, 5.2), ylim=c(0,0.8), axes=F, type="n", ylab="Share of Respondents", xlab="Politician should be jailed")
axis(1, 1:5, c("Agree completely", "Agree", "Neither agree nor disagree", "Disagree", "Disagree completely"), cex.axis=0.8)
axis(2, c(0,0.2, 0.4, 0.6, 0.8))
for(i in 1:5){
	lines(c(i-0.1, i-0.1), c(jail_enrich_low[i], jail_enrich_high[i]), lwd=4)
	lines(c(i+0.1, i+0.1), c(jail_votebuy.low[i], jail_votebuy.high[i]), col="red", lwd=4)
}
points(0.9:4.9, jail_enrich, pch=16, cex=1.5)
points(1.1:5.1, jail_votebuy, pch=16, col="red", cex=1.5)
dev.off()








# Matching

cdata1 <- subset(data, select=c(resign, enrich_treat, age, female, hindu, educ_lower, educ_primary, educ_matric, educ_college, caste_SCST, caste_OBC, caste_Other, household_adults, household_child, income_quintile_1, income_quintile_2, income_quintile_3, income_quintile_4, income_quintile_5, Ac_id, Ac_Ps_id))
cdata1 <- cdata1[complete.cases(cdata1)==T,]
m.out1 <- matchit(enrich_treat ~ age + female + hindu + educ_lower + educ_primary + educ_matric + educ_college + caste_SCST + caste_OBC + caste_Other + household_adults + household_child + income_quintile_1 + income_quintile_2 + income_quintile_3 + income_quintile_4 + income_quintile_5, method="full", data=cdata1)
mdata1 <- match.data(m.out1)


cdata2 <- subset(data, select=c(ban, enrich_treat, age, female, hindu, educ_lower, educ_primary, educ_matric, educ_college, caste_SCST, caste_OBC, caste_Other, household_adults, household_child, income_quintile_1, income_quintile_2, income_quintile_3, income_quintile_4, income_quintile_5, Ac_id, Ac_Ps_id))
cdata2 <- cdata2[complete.cases(cdata2)==T,]
m.out2 <- matchit(enrich_treat ~ age + female + hindu + educ_lower + educ_primary + educ_matric + educ_college + caste_SCST + caste_OBC + caste_Other + household_adults + household_child + income_quintile_1 + income_quintile_2 + income_quintile_3 + income_quintile_4 + income_quintile_5, method="full", data=cdata2)
mdata2 <- match.data(m.out2)


cdata3 <- subset(data, select=c(jail, enrich_treat, age, female, hindu, educ_lower, educ_primary, educ_matric, educ_college, caste_SCST, caste_OBC, caste_Other, household_adults, household_child, income_quintile_1, income_quintile_2, income_quintile_3, income_quintile_4, income_quintile_5, Ac_id, Ac_Ps_id))
cdata3 <- cdata3[complete.cases(cdata3)==T,]
m.out3 <- matchit(enrich_treat ~ age + female + hindu + educ_lower + educ_primary + educ_matric + educ_college + caste_SCST + caste_OBC + caste_Other + household_adults + household_child + income_quintile_1 + income_quintile_2 + income_quintile_3 + income_quintile_4 + income_quintile_5, method="full", data=cdata3)
mdata3 <- match.data(m.out3)


#write.dta(mdata1, file="mdata_1.dta")
#write.dta(mdata2, file="mdata_2.dta")
#write.dta(mdata3, file="mdata_3.dta")




# Table 9
baltab1 <- NULL

bla <- t.test.weight(mdata1$age[mdata1$enrich_treat==0], mdata1$age[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Age", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$female[mdata1$enrich_treat==0], mdata1$female[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Female", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$hindu[mdata1$enrich_treat==0], mdata1$hindu[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Hindu", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$educ_lower[mdata1$enrich_treat==0], mdata1$educ_lower[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Education: Below Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$educ_primary[mdata1$enrich_treat==0], mdata1$educ_primary[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Education: Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$educ_matric[mdata1$enrich_treat==0], mdata1$educ_matric[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Education: Matric", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$educ_college[mdata1$enrich_treat==0], mdata1$educ_college[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Education: College", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$caste_SCST[mdata1$enrich_treat==0], mdata1$caste_SCST[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Caste: SC/ST", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$caste_OBC[mdata1$enrich_treat==0], mdata1$caste_OBC[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Caste: OBC", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$caste_Other[mdata1$enrich_treat==0], mdata1$caste_Other[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Caste: Other", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$household_adults[mdata1$enrich_treat==0], mdata1$household_adults[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Adults in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$household_child[mdata1$enrich_treat==0], mdata1$household_child[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Children in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$income_quintile_1[mdata1$enrich_treat==0], mdata1$income_quintile_1[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Income Quintile: 1", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$income_quintile_2[mdata1$enrich_treat==0], mdata1$income_quintile_2[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Income Quintile: 2", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$income_quintile_3[mdata1$enrich_treat==0], mdata1$income_quintile_3[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Income Quintile: 3", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$income_quintile_4[mdata1$enrich_treat==0], mdata1$income_quintile_4[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Income Quintile: 4", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata1$income_quintile_5[mdata1$enrich_treat==0], mdata1$income_quintile_5[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
baltab1 <- rbind(baltab1, c("Income Quintile: 5", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(baltab1)


# Table 10
baltab2 <- NULL

bla <- t.test.weight(mdata2$age[mdata2$enrich_treat==0], mdata2$age[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Age", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$female[mdata2$enrich_treat==0], mdata2$female[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Female", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$hindu[mdata2$enrich_treat==0], mdata2$hindu[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Hindu", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$educ_lower[mdata2$enrich_treat==0], mdata2$educ_lower[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Education: Below Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$educ_primary[mdata2$enrich_treat==0], mdata2$educ_primary[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Education: Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$educ_matric[mdata2$enrich_treat==0], mdata2$educ_matric[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Education: Matric", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$educ_college[mdata2$enrich_treat==0], mdata2$educ_college[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Education: College", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$caste_SCST[mdata2$enrich_treat==0], mdata2$caste_SCST[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Caste: SC/ST", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$caste_OBC[mdata2$enrich_treat==0], mdata2$caste_OBC[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Caste: OBC", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$caste_Other[mdata2$enrich_treat==0], mdata2$caste_Other[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Caste: Other", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$household_adults[mdata2$enrich_treat==0], mdata2$household_adults[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Adults in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$household_child[mdata2$enrich_treat==0], mdata2$household_child[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Children in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$income_quintile_1[mdata2$enrich_treat==0], mdata2$income_quintile_1[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Income Quintile: 1", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$income_quintile_2[mdata2$enrich_treat==0], mdata2$income_quintile_2[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Income Quintile: 2", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$income_quintile_3[mdata2$enrich_treat==0], mdata2$income_quintile_3[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Income Quintile: 3", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$income_quintile_4[mdata2$enrich_treat==0], mdata2$income_quintile_4[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Income Quintile: 4", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$income_quintile_5[mdata2$enrich_treat==0], mdata2$income_quintile_5[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
baltab2 <- rbind(baltab2, c("Income Quintile: 5", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(baltab2)


# Table 11
baltab3 <- NULL

bla <- t.test.weight(mdata3$age[mdata3$enrich_treat==0], mdata3$age[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Age", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$female[mdata3$enrich_treat==0], mdata3$female[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Female", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$hindu[mdata3$enrich_treat==0], mdata3$hindu[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Hindu", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$educ_lower[mdata3$enrich_treat==0], mdata3$educ_lower[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Education: Below Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$educ_primary[mdata3$enrich_treat==0], mdata3$educ_primary[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Education: Primary", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$educ_matric[mdata3$enrich_treat==0], mdata3$educ_matric[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Education: Matric", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$educ_college[mdata3$enrich_treat==0], mdata3$educ_college[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Education: College", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$caste_SCST[mdata3$enrich_treat==0], mdata3$caste_SCST[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Caste: SC/ST", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$caste_OBC[mdata3$enrich_treat==0], mdata3$caste_OBC[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Caste: OBC", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$caste_Other[mdata3$enrich_treat==0], mdata3$caste_Other[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Caste: Other", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$household_adults[mdata3$enrich_treat==0], mdata3$household_adults[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Adults in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$household_child[mdata3$enrich_treat==0], mdata3$household_child[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Children in Household", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$income_quintile_1[mdata3$enrich_treat==0], mdata3$income_quintile_1[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Income Quintile: 1", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$income_quintile_2[mdata3$enrich_treat==0], mdata3$income_quintile_2[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Income Quintile: 2", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$income_quintile_3[mdata3$enrich_treat==0], mdata3$income_quintile_3[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Income Quintile: 3", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$income_quintile_4[mdata3$enrich_treat==0], mdata3$income_quintile_4[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Income Quintile: 4", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$income_quintile_5[mdata3$enrich_treat==0], mdata3$income_quintile_5[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
baltab3 <- rbind(baltab3, c("Income Quintile: 5", round(bla$estimate, 3), round(bla$p.value, 3)))


xtable(baltab3)


# Table 12
meandiff <- NULL

bla <- t.test.weight(mdata1$resign[mdata1$enrich_treat==0], mdata1$resign[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
meandiff <- rbind(meandiff, c("Resign", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$ban[mdata2$enrich_treat==0], mdata2$ban[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
meandiff <- rbind(meandiff, c("Ban", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$jail[mdata3$enrich_treat==0], mdata3$jail[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
meandiff <- rbind(meandiff, c("Jail", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(meandiff)


# Table 13
mdata1$resign_1 <- ifelse(mdata1$resign==1, 1, 0)
mdata1$resign_2 <- ifelse(mdata1$resign==2, 1, 0)
mdata1$resign_3 <- ifelse(mdata1$resign==3, 1, 0)
mdata1$resign_4 <- ifelse(mdata1$resign==4, 1, 0)
mdata1$resign_5 <- ifelse(mdata1$resign==5, 1, 0)

mdata2$ban_1 <- ifelse(mdata2$ban==1, 1, 0)
mdata2$ban_2 <- ifelse(mdata2$ban==2, 1, 0)
mdata2$ban_3 <- ifelse(mdata2$ban==3, 1, 0)
mdata2$ban_4 <- ifelse(mdata2$ban==4, 1, 0)
mdata2$ban_5 <- ifelse(mdata2$ban==5, 1, 0)

mdata3$jail_1 <- ifelse(mdata3$jail==1, 1, 0)
mdata3$jail_2 <- ifelse(mdata3$jail==2, 1, 0)
mdata3$jail_3 <- ifelse(mdata3$jail==3, 1, 0)
mdata3$jail_4 <- ifelse(mdata3$jail==4, 1, 0)
mdata3$jail_5 <- ifelse(mdata3$jail==5, 1, 0)


catdiff <- NULL
bla <- t.test.weight(mdata1$resign_1[mdata1$enrich_treat==0], mdata1$resign_1[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
catdiff <- rbind(catdiff, c("Resign", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata1$resign_2[mdata1$enrich_treat==0], mdata1$resign_2[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
catdiff <- rbind(catdiff, c("Resign", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata1$resign_3[mdata1$enrich_treat==0], mdata1$resign_3[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
catdiff <- rbind(catdiff, c("Resign", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata1$resign_4[mdata1$enrich_treat==0], mdata1$resign_4[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
catdiff <- rbind(catdiff, c("Resign", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata1$resign_5[mdata1$enrich_treat==0], mdata1$resign_5[mdata1$enrich_treat==1], mdata1$weight[mdata1$enrich_treat==0], mdata1$weight[mdata1$enrich_treat==1])
catdiff <- rbind(catdiff, c("Resign", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata2$ban_1[mdata2$enrich_treat==0], mdata2$ban_1[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
catdiff <- rbind(catdiff, c("Ban", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata2$ban_2[mdata2$enrich_treat==0], mdata2$ban_2[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
catdiff <- rbind(catdiff, c("Ban", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata2$ban_3[mdata2$enrich_treat==0], mdata2$ban_3[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
catdiff <- rbind(catdiff, c("Ban", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata2$ban_4[mdata2$enrich_treat==0], mdata2$ban_4[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
catdiff <- rbind(catdiff, c("Ban", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata2$ban_5[mdata2$enrich_treat==0], mdata2$ban_5[mdata2$enrich_treat==1], mdata2$weight[mdata2$enrich_treat==0], mdata2$weight[mdata2$enrich_treat==1])
catdiff <- rbind(catdiff, c("Ban", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

bla <- t.test.weight(mdata3$jail_1[mdata3$enrich_treat==0], mdata3$jail_1[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
catdiff <- rbind(catdiff, c("Jail", "Agree completely", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata3$jail_2[mdata3$enrich_treat==0], mdata3$jail_2[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
catdiff <- rbind(catdiff, c("Jail", "Agree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata3$jail_3[mdata3$enrich_treat==0], mdata3$jail_3[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
catdiff <- rbind(catdiff, c("Jail", "Neither agree nor disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata3$jail_4[mdata3$enrich_treat==0], mdata3$jail_4[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
catdiff <- rbind(catdiff, c("Jail", "Disagree", round(bla$estimate, 3), round(bla$p.value, 3)))
bla <- t.test.weight(mdata3$jail_5[mdata3$enrich_treat==0], mdata3$jail_5[mdata3$enrich_treat==1], mdata3$weight[mdata3$enrich_treat==0], mdata3$weight[mdata3$enrich_treat==1])
catdiff <- rbind(catdiff, c("Jail", "Disagree completely", round(bla$estimate, 3), round(bla$p.value, 3)))

xtable(catdiff)


